{include file="com:he" /}
<div id="boxes" style="width: 98vw">
    <blockquote class="layui-elem-quote">
        追加apk
    </blockquote>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block">
                <input type="text" name="title" required lay-verify="required" v-model="name" placeholder="请输入名称"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">版本</label>
            <div class="layui-input-block">
                <input type="text" name="title" required lay-verify="required" v-model="ver" placeholder="请输入版本"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">下载地址</label>
            <div class="layui-input-block">
                <input type="text" name="title" required lay-verify="required" v-model="url" placeholder="请输入下载地址"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">文本域</label>
            <div class="layui-input-block">
                <script id="container" name="content" v-model="desc" type="text/plain">
                   <h1></h1>

                </script>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" type="button" @click="add()">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
{include file="com:footer" /}

<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('container', {
        initialFrameHeight: 240,
        autoHeightEnabled: true,
        autoFloatEnabled: true,
    });
    $(function () {
        showVue();
        function showVue() {
            var middle_bot = new Vue({
                el: '#boxes',
                data: {
                    appList: [],
                    name: '',
                    url:'',
                    ver: '',
                    desc: ''
                },
                methods: {
                    add() {
                        if (this.name == "") {
                            layer.msg("为空");
                            return false;
                        }
                        if (this.ver == "") {
                            layer.msg("版本号为空");
                            return false;
                        }
                        $.ajax({
                            type: "post",
                            url: "{:url('index/api/add')}",
                            data: {
                                name: middle_bot.name,
                                ver: middle_bot.ver,
                                desc: ue.getContent(),
                                url: middle_bot.url
                            },
                            dataType: 'json',
                            success: function (data) {
                                layer.msg(data.msg);
                                console.log(JSON.stringify(data));
                            },
                            error: function (res) {
                                layer.msg("错误");
                                console.log(JSON.stringify(res));
                            }
                        })

                    }

                }
            });


        }

    })

</script>